package com.lg.happyfarmer.fragment;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.hemaapp.hm_FrameWork.HemaNetTask;
import com.hemaapp.hm_FrameWork.result.HemaBaseResult;
import com.lg.happyfarmer.R;
import com.lg.happyfarmer.adapter.FirstRecyclerAdapter;
import com.lg.happyfarmer.base.BaseApplication;
import com.lg.happyfarmer.base.BaseFragment;
import com.lg.happyfarmer.bean.Bank;
import com.lg.happyfarmer.untils.SpaceItemDecoration;

import java.util.ArrayList;

/**
 * 易选
 * Created by Torres on 2018/4/25.
 */

public class EasySelectFragment extends BaseFragment{

    private int position;
    public EasySelectFragment() {
        super();
    }
    private FirstRecyclerAdapter adapter;
    private ArrayList<Bank> banks=new ArrayList<>();
    public static EasySelectFragment getInstance(int position) {
        EasySelectFragment fragment = new EasySelectFragment();
        fragment.position = position;
        return fragment;
    }

    private RecyclerView rec_first;
    public void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_listview);
        super.onCreate(savedInstanceState);
        banks.add(new Bank());
        banks.add(new Bank());
        banks.add(new Bank());
        banks.add(new Bank());
        banks.add(new Bank());
        banks.add(new Bank());
        if(adapter==null){
            adapter = new FirstRecyclerAdapter( getActivity(),banks);
            rec_first.setAdapter(adapter);
        }else{
            adapter.resetData(banks);
        }

    }
    @Override
    protected void callBeforeDataBack(HemaNetTask hemaNetTask) {

    }

    @Override
    protected void callAfterDataBack(HemaNetTask hemaNetTask) {

    }

    @Override
    protected void callBackForServerSuccess(HemaNetTask hemaNetTask, HemaBaseResult hemaBaseResult) {

    }

    @Override
    protected void callBackForServerFailed(HemaNetTask hemaNetTask, HemaBaseResult hemaBaseResult) {

    }

    @Override
    protected void callBackForGetDataFailed(HemaNetTask hemaNetTask, int i) {

    }

    @Override
    protected void findView() {
        rec_first= (RecyclerView) findViewById(R.id.rec_first);

        LinearLayoutManager layoutManager = new LinearLayoutManager(BaseApplication.getInstance());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        rec_first.addItemDecoration(new SpaceItemDecoration(5));
        rec_first.setLayoutManager(layoutManager);



//        RecycleUtils.initVerticalRecyle(rec_first);
    }

    @Override
    protected void setListener() {

    }
}
